package com.acwing.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/5/5 9:20
 */
public class AC1986镜子 {

    private static final int N = 210, INF = 0x3f3f3f3f;
    private static final int[][] dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    private static Mirror[] mirrors = new Mirror[N];
    private static int n;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        mirrors[0] = new Mirror(0, 0, ' ');
        mirrors[n + 1] = new Mirror(Integer.parseInt(ss[1]), Integer.parseInt(ss[2]), ' ');
        for (int i = 1; i <= n; i++) {
            ss = reader.readLine().split(" ");
            int x = Integer.parseInt(ss[0]), y = Integer.parseInt(ss[1]);
            char c = ss[2].charAt(0);
            mirrors[i] = new Mirror(x, y, c);
        }
        if (check()) writer.write("0\n");
        else {
            int ans = -1;
            for (int i = 1; i <= n; i++) {
                rotate(mirrors[i]);
                if (check()) {
                    ans = i;
                    break;
                }
                rotate(mirrors[i]);
            }
            writer.write(ans + "\n");
        }
        writer.flush();
    }

    private static boolean check() {
        //k表示当前到达的点的下标
        int d = 1, k = 0;
        for (int i = 0; i < 2 * (n + 1); i++) {
            //以当前点k在当前方向dir上找到第一个最近的点
            int id = -1, len = INF;
            for (int j = 1; j <= n + 1; j++) {
                if (k == j) continue;
                if (mirrors[k].x + Math.abs(mirrors[k].x - mirrors[j].x) * dirs[d][0] != mirrors[j].x) continue;
                if (mirrors[k].y + Math.abs(mirrors[k].y - mirrors[j].y) * dirs[d][1] != mirrors[j].y) continue;
                int t = Math.abs(mirrors[k].x - mirrors[j].x) + Math.abs(mirrors[k].y - mirrors[j].y);
                if (t < len) {
                    len = t;
                    id = j;
                }
            }
            if (id == -1) return false;
            if (id == n + 1) return true;
            k = id;
            if (mirrors[id].c == '/') d ^= 1;
            else d ^= 3;
        }
        //出现了环
        return false;
    }

    private static void rotate(Mirror mirror) {
        if (mirror.c == '\\') mirror.c = '/';
        else mirror.c = '\\';
    }

    private static class Mirror {
        private int x, y;
        private char c;

        public Mirror(int x, int y, char c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }
    }
}
